package com.qf.day08;

import java.util.Random;

public class WeaponUtils {

    public static  Weapon[]  getWeaponnsArr(int num) {
        Weapon[] weapons = new Weapon[num];
        Random random = new Random();
        for (int i = 0; i < weapons.length; i++) {
            switch(random.nextInt(2)){
                case 0:
                    Sword sword = new Sword();
                    String[] names = {"越王勾践剑","太极八卦剑","轩辕剑","赤霄剑"};
                    sword.setName(names[random.nextInt(names.length)]);
                    String[] colors = {"银色","金色","黑色"};
                    sword.setColor(colors[random.nextInt(colors.length)]);
                    String[] types = {"长剑","短剑","双股剑"};
                    sword.setType(types[random.nextInt(types.length)]);
                    sword.setWeight(10+random.nextInt(20));
                    weapons[i]=sword;
                    break;
                case 1:
                    Dagger dagger = new Dagger();
                    String[] dNames = {"小匕首","大匕首","爪刀","蝴蝶刀"};
                    dagger.setName(dNames[random.nextInt(dNames.length)]);
                    dagger.setHeight(10+random.nextInt(20));
                    String[] dTypes = {"小","大","双"};
                    dagger.setType(dTypes[random.nextInt(dTypes.length)]);
                    dagger.setWeight(10+random.nextInt(20));
                    dagger.setHeight(10+random.nextInt(20));
                    weapons[i]=dagger;
                    break;
            }
        }
        return weapons;
    }

}
